package zz.extjs.util;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServlet;

public class EncodingFilter extends HttpServlet implements Filter {
    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private FilterConfig config;
    private String encodeing;

    public void init(FilterConfig config) throws ServletException {
        this.config = config;
        this.encodeing = config.getInitParameter("encoding");
    }

    public void doFilter(ServletRequest request, ServletResponse response,
                         FilterChain filterChain) throws IOException,
            ServletException {
        request.setCharacterEncoding(encodeing);

        filterChain.doFilter(request, response);
    }

    public void destroy() {
        super.destroy();
    }
}
